import { createRouter, createWebHashHistory, createWebHistory, RouteRecordRaw } from 'vue-router'
import Canvas from '../packages/components/YkImageDisplay/YkImageDisplay.vue'
import Video from '../packages/components/YkVideo/YkVideo.vue'
// import useLogin from './useLogin.vue'
import YkVueFlow from '../packages/components/YkVueFlow/YkVueFlow.vue'
import useEbsFlow from './useEbsFlow.vue'
import TempPage from '@/components/TempPage/TempPage.vue'
import { YkUserCard } from '@/index.ts'
import { createLoginComponent } from '../packages/components/LoginPage/useLogin'
import packageJson from '../package.json'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Login',
    component: createLoginComponent({
      appName: packageJson.name,
      redirectPath: '/home' // 自定义重定向路径，不设置则为/home
    })
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('../packages/components/SgesCalC/SgesCalC.vue') // 替换为你实际的首页组件
  },
  {
    path: '/TempPage',
    name: 'TempPage',
    component: TempPage
  },

  {
    path: '/SgesCalC',
    name: 'SgesCalC',
    component: () => import('../packages/components/SgesCalC/SgesCalC.vue')
  },
  {
    path: '/SgesCalA',
    name: 'SgesCalA',
    component: () => import('../packages/components/SgesCalA/SgesCalA.vue')

  },
  {
    path: '/Canvas',
    name: 'Canvas',
    component: Canvas
  },
  {
    path: '/Video',
    name: 'Video',
    component: Video
  },
  {
    path: '/EbsFlow',
    name: 'EbsFlow',
    component: useEbsFlow
  },
  {
    path: '/VueFlow',
    name: 'VueFlow',
    component: YkVueFlow
  },
  {
    path: '/UserCard',
    name: 'UserCard',
    component: YkUserCard
  }
]
const router = createRouter({
  history: createWebHistory(),
  routes: routes
})

// 全局前置守卫
// router.beforeEach((to, from, next) => {
//   const isAuthenticated = !!localStorage.getItem('authToken') // 假设我们使用localStorage存储认证令牌
//   if (to.matched.some(record => record.meta.requiresAuth) && !isAuthenticated) {
//     // 如果目标路由需要登录且用户未登录，则重定向到登录页面
//     next({
//       path: '/login',
//       query: { redirect: to.fullPath } // 可以将当前路由的路径作为参数传递给登录页面，以便登录后重定向回来
//     })
//   } else {
//     // 否则，继续导航
//     next()
//   }
// })
export default router